﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.Serialization;

namespace LLClient.SaveAndLoad
{
    [Serializable()]
    public class LLFile : ISerializable
    {
        private string captain1Name;
        private string captain2Name;
        private Dictionary<int, int> field1;
        private Dictionary<int, int> field2;
        private List<TurnSerialized> turns;

        #region Properties

        public string Captain1Name
        {
            get { return captain1Name; }
            set { captain1Name = value; }
        }

        public string Captain2Name
        {
            get { return captain2Name; }
            set { captain2Name = value; }
        }

        public Dictionary<int, int> Field1
        {
            get { return field1; }
            set { field1 = value; }
        }

        public Dictionary<int, int> Field2
        {
            get { return field2; }
            set { field2 = value; }
        }

        public List<TurnSerialized> Turns
        {
            get { return turns; }
            set { turns = value; }
        }

        #endregion

        public LLFile()
        {
            turns = new List<TurnSerialized>();
        }

        #region Serialization

        public LLFile(SerializationInfo info, StreamingContext ctxt)
        {
            this.captain1Name = (string)info.GetValue("Captain1Name", typeof(string));
            this.captain2Name = (string)info.GetValue("Captain2Name", typeof(string));
            this.field1 = (Dictionary<int, int>)info.GetValue("Field1", typeof(Dictionary<int, int>));
            this.field2 = (Dictionary<int, int>)info.GetValue("Field2", typeof(Dictionary<int, int>));
            this.turns = (List<TurnSerialized>)info.GetValue("Turns", typeof(List<TurnSerialized>));
        }

        public void GetObjectData(SerializationInfo info, StreamingContext context)
        {
            info.AddValue("Captain1Name", this.captain1Name);
            info.AddValue("Captain2Name", this.captain2Name);
            info.AddValue("Field1", this.field1);
            info.AddValue("Field2", this.field2);
            info.AddValue("Turns", this.turns);
        }

        #endregion
    }
}
